<template>
  <div class="goods-list">
    <img :src="goodsItem.imgUrl" alt="" @load="imgLoad" />
    <div class="list-text">
      <p class="title">{{ goodsItem.title }}</p>
      <span class="price">{{ goodsItem.price }}</span>
      <span class="sale">{{ goodsItem.thumb }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  methods: {
    imgLoad() {
      this.$bus.$emit("itemImgLoad");
    },
  },
};
</script>

<style lang="less" scoped>
.goods-list {
  width: 48vw;
  padding: 5px 10px;
  box-sizing: border-box;
  font-size: 1rem;
  float: left;
  box-shadow: 0px 2px 1px 0px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  margin: 1%;
  background-color: #fff;
  img {
    width: 100%;
    border-radius: 4px;
  }
  .list-text {
    .title {
      display: inline-block;
      width: 100%;
      font-size: 12px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .price {
      float: left;
      color: var(--color-high-text);
      font-weight: bold;
    }
    .sale {
      float: right;
      position: relative;
      color: var(--color-high-text);
      &::before {
        content: "";
        position: absolute;
        left: -15px;
        top: 2px;
        width: 14px;
        height: 14px;
        background: url("@/assets/images/common/collect.svg");
        background-size: contain;
      }
    }
  }
}
</style>
